import axios from "axios";
import {LoginData, LoginRes} from "@/api/user";
import {configs} from "@typescript-eslint/eslint-plugin";

export interface PopularRecord {
    key: number;
    clickNumber: string;
    title: string;
    increases: number;
}
export interface PolicyRecord {
    id: number;
    cat_id: number;
    cat_second_id: number;
    code: string;
    purchase_voucher:string;
    create_time: string;
    status: number;
    cat_name: string;
    cat_second_name: string;
}

export interface PolicyParams extends Partial<PolicyRecord> {
    current: number;
    pageSize: number;
    selected:number;
    isSecond:number;
}
export interface Pagination {
    current: number;
    pageSize: number;
    total?: number;
    selected:number;
    isSecond:number;
}


export function getProductCatTree() {
    return axios.get<any>('/admin/product_cat/tree');
}
export function addProductionCat(data:any) {
    return axios.post<any>('/admin/product_cat/add',data);
}






export function queryProductionList(data:any) {
    console.log(data)
    let params = {
        page:data.current,
        page_size:data.pageSize,
        cat_id:null,
        cat_second_id:null
    };
    if (data.isSecond==0){
        params.cat_id = data.selected;
        delete params.cat_second_id
    }else {
        params.cat_second_id = data.selected;
        delete params.cat_id
    }
    return axios.get<any>('/admin/product/list', {
        params
    });
}


export function productList(params:any) {
  
    return axios.get<any>('/admin/product/list', {
        params
    });
}



export function contentTypeOptionsCatPlateVersion(data:any) {
    console.log(data)
    return axios.get<any>('/admin/cat_plate_version/list',{
        params: {
            cat_second_id:data.value
        }
    });
}
//
export function contentTypeOptionsCatCircuitVersion() {
    return axios.get<any>('/admin/cat_circuit_version/list',);
}
export function addProductionInfo(data:any) {
    return axios.post<any>('/admin/product/add',data);
}
export function editProductionCat(data:any) {
    return axios.post<any>('/admin/product_cat/edit',data);
}
export function deleteProductionCat(data:any) {
    return axios.post<any>('/admin/product_cat/del',data);
}
//修改机器状态
export function editStatus(data:any) {
    return axios.post<any>('/admin/product/status_edit',data);
}




export function changeStatus(data:any) {
    return axios.post<any>('/admin/product/status_edit',data);
}

export function delProduction(data:any) {
    return axios.post<any>('/admin/product/del',{id:data});
}




export function productionListDetail(data:any) {
    return axios.get<any>(`/admin/product/detail?id=${data}`);
}




export function productTree() {
    return axios.get<any>(`/admin/product_cat/tree`);
}
export function producOne() {
    return axios.get<any>(`/admin/product_cat/one`);
}
export function addproducOne(data) {
    return axios.post<any>(`/admin/product_cat/add`,data);
}

